//
//  ExpertDetailsSimilarityExpert.m
//
//  Created by 啊  on 16/5/10
//  Copyright (c) 2016 __MyCompanyName__. All rights reserved.
//

#import "ExpertDetailsSimilarityExpert.h"


NSString *const kExpertDetailsSimilarityExpertEId = @"eId";
NSString *const kExpertDetailsSimilarityExpertEName = @"eName";
NSString *const kExpertDetailsSimilarityExpertEDiscussion = @"eDiscussion";
NSString *const kExpertDetailsSimilarityExpertEAppellation = @"eAppellation";
NSString *const kExpertDetailsSimilarityExpertEConsultancyNum = @"eConsultancyNum";
NSString *const kExpertDetailsSimilarityExpertEHeadUrl = @"eHeadUrl";


@interface ExpertDetailsSimilarityExpert ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation ExpertDetailsSimilarityExpert

@synthesize eId = _eId;
@synthesize eName = _eName;
@synthesize eDiscussion = _eDiscussion;
@synthesize eAppellation = _eAppellation;
@synthesize eConsultancyNum = _eConsultancyNum;
@synthesize eHeadUrl = _eHeadUrl;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if(self && [dict isKindOfClass:[NSDictionary class]]) {
            self.eId = [[self objectOrNilForKey:kExpertDetailsSimilarityExpertEId fromDictionary:dict] doubleValue];
            self.eName = [self objectOrNilForKey:kExpertDetailsSimilarityExpertEName fromDictionary:dict];
            self.eDiscussion = [self objectOrNilForKey:kExpertDetailsSimilarityExpertEDiscussion fromDictionary:dict];
            self.eAppellation = [self objectOrNilForKey:kExpertDetailsSimilarityExpertEAppellation fromDictionary:dict];
            self.eConsultancyNum = [[self objectOrNilForKey:kExpertDetailsSimilarityExpertEConsultancyNum fromDictionary:dict] doubleValue];
            self.eHeadUrl = [self objectOrNilForKey:kExpertDetailsSimilarityExpertEHeadUrl fromDictionary:dict];

    }
    
    return self;
    
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:[NSNumber numberWithDouble:self.eId] forKey:kExpertDetailsSimilarityExpertEId];
    [mutableDict setValue:self.eName forKey:kExpertDetailsSimilarityExpertEName];
    [mutableDict setValue:self.eDiscussion forKey:kExpertDetailsSimilarityExpertEDiscussion];
    [mutableDict setValue:self.eAppellation forKey:kExpertDetailsSimilarityExpertEAppellation];
    [mutableDict setValue:[NSNumber numberWithDouble:self.eConsultancyNum] forKey:kExpertDetailsSimilarityExpertEConsultancyNum];
    [mutableDict setValue:self.eHeadUrl forKey:kExpertDetailsSimilarityExpertEHeadUrl];

    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description 
{
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];

    self.eId = [aDecoder decodeDoubleForKey:kExpertDetailsSimilarityExpertEId];
    self.eName = [aDecoder decodeObjectForKey:kExpertDetailsSimilarityExpertEName];
    self.eDiscussion = [aDecoder decodeObjectForKey:kExpertDetailsSimilarityExpertEDiscussion];
    self.eAppellation = [aDecoder decodeObjectForKey:kExpertDetailsSimilarityExpertEAppellation];
    self.eConsultancyNum = [aDecoder decodeDoubleForKey:kExpertDetailsSimilarityExpertEConsultancyNum];
    self.eHeadUrl = [aDecoder decodeObjectForKey:kExpertDetailsSimilarityExpertEHeadUrl];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeDouble:_eId forKey:kExpertDetailsSimilarityExpertEId];
    [aCoder encodeObject:_eName forKey:kExpertDetailsSimilarityExpertEName];
    [aCoder encodeObject:_eDiscussion forKey:kExpertDetailsSimilarityExpertEDiscussion];
    [aCoder encodeObject:_eAppellation forKey:kExpertDetailsSimilarityExpertEAppellation];
    [aCoder encodeDouble:_eConsultancyNum forKey:kExpertDetailsSimilarityExpertEConsultancyNum];
    [aCoder encodeObject:_eHeadUrl forKey:kExpertDetailsSimilarityExpertEHeadUrl];
}

- (id)copyWithZone:(NSZone *)zone
{
    ExpertDetailsSimilarityExpert *copy = [[ExpertDetailsSimilarityExpert alloc] init];
    
    if (copy) {

        copy.eId = self.eId;
        copy.eName = [self.eName copyWithZone:zone];
        copy.eDiscussion = [self.eDiscussion copyWithZone:zone];
        copy.eAppellation = [self.eAppellation copyWithZone:zone];
        copy.eConsultancyNum = self.eConsultancyNum;
        copy.eHeadUrl = [self.eHeadUrl copyWithZone:zone];
    }
    
    return copy;
}


@end
